/********迷你购物车加减********/
/* lkl修改 */
	function flowClickCartNum(a,b,obj)
	{
		
		var b = parseInt(b);
		var c = $("#goods_number_"+a);
		var d = parseInt(c.val());
		if(d < 1 || !$.isNumeric(d))
		{
			alert("请输入正确的商品数量");	
			e = 1;
		}
		
		if(b == -1)		
		{
			if(d == 1)
			{
				alert("购买数量不能小于1件");	
			}
			else
			{
				e = d + b;
			}
		}
		else
		{
			e = d + b;
		}
		
		/* lkl判断此商品有没有被选中 */
		var check = obj.parents('.item-row').find('.tcheck').is(':checked');
		flow_change_goods_number(a,e,check);
	}
	/* lkl修改 */
	function flow_change_goods_number(rec_id, goods_number, check)
	{     
		Ajax.call('flow.php?step=ajax_update_cart', 'rec_id=' + rec_id +'&goods_number=' + goods_number + '&check='+check, flow_change_goods_number_response, 'POST','JSON');
	}
	function flow_change_goods_number_response(result)
	{              
	
		if (result.error == 0)
		{
			var rec_id = result.rec_id;
			
			$('#goods_number_' +rec_id).val(result.goods_number);//更新数量	
			$('#total_items_' +rec_id).html(result.goods_subtotal);//更新小计	
			$('#totalSkuPrice').html(result.total_price); //更新合计
			
			$('#selectedCount').html(result.total_goods_count);//更新购物车数量
			//$('#totalRePrice').html("- "+result.total_saving) //更新节省

		}else if (result.error == 100)
		{
			document.getElementById('goods_number_'+result.rec_id).value=2;//更新数量
			alert(result.message);
		}
		else if (result.message != '')
		{
			alert(result.message);                
		}
	}
	
	
$(function(){
	
	//鼠标经过商品配件，按钮显示
	$("#page-btm li").mouseenter(function(){
		$(this).find("#add-cart").show();	
	}).mouseleave(function(){
		$(this).find("#add-cart").hide();	
	});
	
	//确认收货点击点选按钮，样式切换
	$(".item-list li label").click(function(){
		var radio=$(this).find("input:radio");
		if(radio.prop("disabled")==true){alert("失效");return false;}
		radio.val("110");
		$(this).parent("li").addClass("active").siblings().removeClass("active");
	});
	
	//加载时的样式
	$(".item-list li label input:radio").each(function(index, element) {
        if($(this).attr("checked")){
			$(this).parent().parent().addClass("active");	
		}
        if($(this).attr("disabled")){
			$(this).parent().parent().addClass("disabled");	
		}
    });
	
	
	$(".item-list li").hover(function(){
		$(this).find(".text").show();	
	},function(){
		$(this).find(".text").hide();
	});
	
});

function checkradio(name){
	$("input[name="+name+"]:checked").each(function(index, element) {
        
    });
	if($(this).siblings("input[name=how_oos]:checked")){
		$(this).parent("li").addClass("active").siblings().removeClass("active");
	}
}


/* lkl增加选择结算 S*/
	function chkAll_onclick(){
		var obj = document.getElementById('chkAll');
		var obj_cartgoods = document.getElementsByName("sel_cartgoods[]");
		for (var i=0;i<obj_cartgoods.length;i++){
            if(!obj_cartgoods[i].disabled){
                var e = obj_cartgoods[i];

                if (e.name != 'chkAll'){
                    e.checked = obj.checked;
                }
            }
		}
		select_cart_goods();
	}
	function select_cart_goods(){
	      var sel_goods = new Array();
	      var obj_cartgoods = document.getElementsByName("sel_cartgoods[]");
	      var j=0;
	      var c = true;
	      for (i=0;i<obj_cartgoods.length;i++){
			if(obj_cartgoods[i].checked == true){	
				sel_goods[j] = obj_cartgoods[i].value;
				j++;
			}else{
				c = false;
			}
	      }
	      document.getElementById('chkAll').checked = c;
	      Ajax.call('flow.php', 'act=selcart&sel_goods=' + sel_goods  , selcartResponse, 'GET', 'JSON');
	}
	function selcartResponse(res){
	  if (res.err_msg.length > 0){
            alert(res.err_msg);
	  }else{
	     document.getElementById('totalSkuPrice').innerHTML = res.result;
	  }
	}
	
	

/* lkl增加选择结算 E*/